<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateElOrderItemTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('el_order_item', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id')->unsigned();

            /*$table->integer('goods_id')->unsigned()->nullable();
            $table->integer('product_id')->unsigned()->nullable();
            $table->string('product_name')->nullable();*/
            $table->integer('item_id')->unsigned();
            $table->string('item_name');
            $table->string('type');
            $table->text('item_meta')->nullable()->default(null);


            $table->integer('quantity')->unsigned();  //商品数量
            $table->integer('unit_price');   //商品单价
            $table->integer('units_total')->unsigned();          //商品总价 = unit_price * quantity
            $table->integer('adjustments_total')->default(0)->nullable();     //总的优惠金额

            $table->integer('total');   //unitPrice * quantity - adjustmentsTotal


            /*this old field
            $table->string('goods_name');
            $table->string('img')->nullable();
            $table->decimal('goods_price', 8, 2)->default(0.00);   //商品价
            $table->integer('goods_nums')->unsigned();
            $table->text('goods_array')->nullable()->default(null); //商品和货品名称name和规格value串json数据格式
            $table->integer('is_send')->unsigned()->default(0); //0:未发货 1：已发货  2：已退货 3:退货中 4：已换货  5：换货中
            */

            $table->timestamps();
            $table->softDeletes();

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('el_order_item');
    }
}
